#ifndef _FILEREADER_H
#define _FILEREADER_H

#include <stdio.h>
#include "stdlib.h"
#include "string.h"
#include "log.h"

const int MAX_LINE_SIZE = 255;

/*------------------------------------------------------------------------------
	FileReader
	Reads configuration files. Config files can use "#" as first line character 
	to add comments and ";" to separate config fields.
	Config file example:
	
	#NPC Details, separated by ";"
	Drizzt Do'Urden;Drizzt is an unusual specimen of the predominantly evil drow race.
	#NPC Dialogs, One dialog per line
	I'm gonna kill you bastard
	This is great!

------------------------------------------------------------------------------*/
class FileReader
{

public:

	FileReader();
	~FileReader();
	bool init(const char *_filename);
	void freeMemory();
	char *readLine(int _size);
	
	char *find(const char *_fieldname);
	char *getValue(const char *_fieldname,const int _field_pos);
	char *readField(const char *_line,int _field_pos);

private:

	FILE *m_file;
	Log  *m_pLog;

};


#endif // ifndef _FILEREADER_H
